/**
 *
 */
package hichecker.ui.components.verifier;

import hichecker.controller.Config;
import hichecker.university.SemesterDate;

import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
 *
 */
public class SemesterVerifier extends InputVerifier {
	private JLabel errorLabel;

	public SemesterVerifier(JLabel errorLabel) {
		this.errorLabel = errorLabel;
	}

	@Override
	public boolean verify(JComponent input) {
		String inputText = ((JTextField) input).getText();
		if (SemesterDate.isValidSemesterDate(inputText)) {
			errorLabel.setText(null);
			return true;
		}
		else {
			errorLabel.setText(Config.POPUP_SEMESTER_INVALID);
			return false;
		}
	}

}
